package main;

//import connectivity.DbManager;
//import connectivity.QueryManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;

import java.awt.Font;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

/**
 *
 * @author Administrator
 */
public final class BarApplication {

    /**
     * the main window
     */
    public static final Font FONT_10_PLAIN = new Font("Verdana", Font.PLAIN, 10);
    public static final Font FONT_10_BOLD = new Font("Verdana", Font.BOLD, 10);
    public static final Font FONT_12_BOLD = new Font("Verdana", Font.BOLD, 12);
    public static final Font FONT_16_BOLD = new Font("Verdana", Font.BOLD, 16);
    public static final String NAME = "Fitshape Sportscholen";
    public static final int FRAME_WIDTH = 960;
    public static final int FRAME_HEIGHT = 650;
    private JFrame mainWindow;
    /**
     * singleton of the application
     */
    private JLabel header = new JLabel();
    //private javax.swing.JLabel header;
    private static BarApplication instance = new BarApplication();

    private BarApplication() {
    }

    public void startup() {
        mainWindow = new JFrame(NAME);
        mainWindow.setSize(FRAME_WIDTH, FRAME_HEIGHT);

        /**
         * Make the window closing [x] button on the frame active
         */
        mainWindow.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent event) {
                shutdown();
            }
        });

        mainWindow.getContentPane().setLayout(new BorderLayout());
        showPanel(new view.ManagerHomePage());

        mainWindow.setLocationRelativeTo(null);
        mainWindow.setVisible(true);
    }

    public void showPanel(JPanel panel) {

        mainWindow.getContentPane().removeAll();
        header.setBorder(BorderFactory.createLineBorder(Color.black, 0));
        header.setPreferredSize(new Dimension(960, 139));
        header.setBackground(Color.WHITE);
        header.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/FitShape_Logo.png"))); // NOI18N

        mainWindow.getContentPane().add(header, BorderLayout.NORTH);

        mainWindow.getContentPane().add(panel, BorderLayout.CENTER);

        mainWindow.getContentPane().validate();
        mainWindow.getContentPane().repaint();
    }

    public void exit() {
        mainWindow.setVisible(false);
        shutdown();
    }

    private void shutdown() {
        mainWindow.dispose();
//        dbManager.closeConnection();
    }

    /**
     * @return the instance of this class
     */
    public static BarApplication getInstance() {
        return instance;
    }

    public static void main(String args[]) {
        final BarApplication applicatie = BarApplication.getInstance();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    //applicatie.initialize();
                    applicatie.startup();
                } catch (Exception e) {
                    System.out.println("Application" + applicatie.getClass().getName() + "failed to launch");
                }
            }
        });
    }
}
